home *** CD-ROM | disk | FTP | other *** search
- Path: news.pi.net!news
- From: mv@pi.net
- Newsgroups: comp.lang.c
- Subject: ** Array problem **
- Date: 20 Jan 1996 10:47:48 GMT
- Organization: IBM OS/2 Warp
- Message-ID: <4dqh8k$ov9@neptunus.pi.net>
- Reply-To: mv@pi.net
- NNTP-Posting-Host: asd44.pi.net
- X-Newsreader: IBM NewsReader/2 v1.03
-
-
- Hello Bill Wendlig (and everybody else),
-
-
- A couple a days ago you replied to a message from me about some
- problems with a piece if code..
- You handed me some tips and corrections about a double indexed array that
- turned out to be a 3-dimensional one..
-
- I implemented you corrections but to no good, it made things even worse...
- But than again I'm not a an experienced C-programmer..
-
- But could you please tell me why this code works...
-
-
- --------------------------------------------
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <malloc.h>
-
-
- char *s;
- char a[20][20];
-
-
-
- int main (void)
-
- {
- int i=0;
-
- s=(char *)malloc(18);
- strcpy(s,"Blah blah, this works");
- for (i=0; i<=15; i++)
- {
- strcpy(a[i],s);
- }
- for (i=0; i<=15; i++)
- {
- printf("%s\n",a[i]);
- }
- free(s);
- return 0;
- }
-
- --------------------------------
-
- This is the same situation but it works fine here ?!
-
-
-
- TTYL,
-
- Martijn Valkier.
-
-